package cn.bytets.rpc.api.invoke;

import cn.bytets.rpc.api.message.Result;
import cn.bytets.rpc.common.URL;

public abstract class AbstractInvoker<T> implements Invoker<T> {

    private Class<T> type;

    private URL url;

    public AbstractInvoker(Class<T> cls,URL url){
        this.type = cls;
        this.url = url;
    }

    @Override
    public URL getUrl() {
        return this.url;
    }

    /**
     * get service interface.
     *
     * @return service interface.
     */
    @Override
    public Class<T> getInterface() {
        return type;
    }

    /**
     * invoke.
     *
     * @param invocation
     * @return result
     * @throws
     */
    @Override
    public Result invoke(Invocation invocation) {
        return doInvoker(invocation);
    }

    public abstract Result doInvoker(Invocation invocation);
}
